package com.eascs.fp.uc.dao;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.eascs.app.dao.JdbcSession;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;
import com.eascs.common.util.StringUtil;
import com.eascs.fp.common.dao.BaseDao;
import com.eascs.fp.common.entity.ApplyLoanEntity;

@Repository
public class MemberCenterDao extends BaseDao{
	
	@Autowired
	@Qualifier("wxSession")
	protected JdbcSession wxSession;

	
	public PageResult<Object[]> queryLoanApplyPage(ApplyLoanEntity entity,int pageSize,int pageIndex) {
		StringBuffer sql=new StringBuffer();
		sql.append(" SELECT id,create_time,loan_type,loan_money,loan_time FROM applay_info");
		sql.append(" WHERE 1=1");
		List<Object> paramsList=new ArrayList<>();
		if (entity!=null) {
			if (StringUtil.hasText(entity.getUserId())) {
				sql.append(" and user_id=?");
				paramsList.add(entity.getUserId());
			}
		}
		Object[] params =paramsList.toArray();
		SqlPageQuery<Object[]> pageQuery = new SqlPageQuery<Object[]>(Object[].class,pageSize,pageIndex,sql.toString());
		pageQuery.addParams(params);
		return wxSession.findDataWithPage(pageQuery);
	}
}
